<template>
  <div>
    <div>
      <van-nav-bar title="流量使用" left-arrow @click-left="gouasge">
        <template #right>
          <van-icon name="ellipsis" />
        </template>
      </van-nav-bar>
    </div>
    <div class="my_contnt">
      <div>
        <span>流量</span>
      </div>
      <div class="my_xiazai">
        <div class="my_hang">
          <div class="my_jianshang">
            <div class="my_jian"><span>↑</span></div>
            <div>下载</div>
          </div>
          <div>
            14,89Mbps
          </div>
        </div>
        <div class="my_shut"></div>
        <div class="my_hang">
          <div class="my_jianshang">
            <div class="my_jianxia"><span>↓</span></div>
            <div>上传</div>
          </div>
          <div>
            10,29Mbps
          </div>
        </div>
      </div>
      <div>
        <div ref="barChart" :style="{  height: '250px' }"></div>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import router from '@/router';
import * as echarts from 'echarts';
import { onMounted, ref } from 'vue';
const gouasge = () => {
  router.push('./Hello')
}
const barChart = ref<HTMLElement>();
const myChart1 = ref<any>();
// 绘制柱形图
function initBarEcharts() {
  myChart1.value = echarts.init(barChart.value!);
  myChart1.value.setOption({
    title: {

      x: 'center'
    },
    tooltip: {
      trigger: 'item'
    },
    legend: {

      orient: 'vertical',
      right: 60,
      top: 20
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
      show: false
    },
    yAxis: {
      type: 'value',
      show: false
    },
    color: ['#7033ff', '#7033ff'],
    series: [
      {
        smooth: true,
        data: [20, 50, 80, 30, 150, 50, 280],
        type: 'line',
        areaStyle: {}
      }
    ],
    grid: {
      x: 0,
      y: 0,
      x2: 0,
      y2: 20,
      borderWidth: 1
    }
  });
}
onMounted(() => {
  initBarEcharts();
});

</script>

<style scoped lang="scss">
.my_contnt {
  padding: 1rem;

  .my_xiazai {
    height: 7rem;
    margin-top: 2rem;
    display: flex;
    justify-content: space-around;
  }

  .my_shut {
    width: 1rem;
    height: 7rem;
    background: #fb8f66;
    background-blend-mode: normal;
  }

  .my_hang {
    line-height: 3rem;
  }

  .my_jian {
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    background-color: #FB8F66;
    text-align: center;
    line-height: 2rem;
    color: #FFFFFF;
    border: 0.2rem solid #ee5c22;

  }

  .my_jianxia {
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    background-color: #7033FF;
    text-align: center;
    line-height: 2rem;
    color: #352C5D;
    border: 0.2rem solid #352C5D;
  }

  .my_jianshang {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-left:1rem;
  }
}
</style>